package ok;

//189
public class rotate {

    // 旋转不是说截取再拼接，是整个数组翻转，再各自翻转
    // 1.数组翻转
    public void rotate(int[] nums, int k) {
        // 取余
        k %= nums.length;
        reverse(nums, 0, nums.length - 1);
        reverse(nums, 0, k - 1);
        reverse(nums, k, nums.length - 1);
    }

    public void reverse(int[] nums, int start, int end) {
        while (start < end) {
            int temp = nums[start];
            nums[start] = nums[end];
            nums[end] = temp;

            start += 1;
            end -= 1;
        }
    }

    public static void main(String[] args) {
        int i = 10;
        System.out.println(i %= 3);
    }

    // 2.使用额外的数组 TODO
}
